// @charset "utf-8";
define(function (require, exports, module) {
	// var control = require('./control');
	var autoLoop = {
		isInpage : true,
		tradingDay : '',
		autodo : function (callback, delay, tradingCall) {
			var self = this;
			var tradingDay = commonMethod.getTradingDay();
			self.tradingDay = tradingDay;
			var getTradeTimer = setInterval(function () {
				if (self.tradingDay != 0) {
					clearInterval(getTradeTimer);
				} else {
					self.tradingDay = commonMethod.getTradingDay();
				}
			}, 200);
			try {
				external.registerEvent({
					onshow: function(inPage) {
						if (inPage) {
							self.isInpage = true;
							setTimeout(function () {
								callback('isIn');
							}, 700);
						} else {
							self.isInpage = false;
							commonMethod.thsQuote.unregisterPush();
						}
					}
				});
			} catch (e) {}
			setInterval(function () {
				if (self.isInpage) {
					callback();
					tradingDay = commonMethod.getTradingDay();
					if (tradingDay != self.tradingDay) {
						self.tradingDay = tradingDay;
						tradingCall(tradingDay);
					}
				}
			}, delay);
		}
	};

	module.exports = autoLoop;
});
